new Vue({
    el: '#app',
    data() {
      return {
        form: {
          serachKey: "",
          page: 1,			//页数
          limit: 10			//每页数据条数
        },
        formData: {},
        article_info: [],
        store_info: [],
        supplier_info: [],
        tableData: [{}],		//表格数据
        total: 1,
        dialogForm: false,
        title: '',
        multipleSelection: []
      }
    },
    mounted() {
      this.getList1()
    },
    computed: {
      formatTime() {
        return function (time) {
          if(time){
            let d = new Date(parseInt(time));
            return `${d.getFullYear()}-${d.getMonth() + 1
              }-${d.getDate()} ${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}`;
          }else{
            return ''
          }  
        };
      },
      Article_Name() {
        return function (id) {
          if (this.article_info.length > 0) {
            let obj = this.article_info.filter(item => {
              return item.Article_SerialNumber == id
            })[0]
            if (obj) {
              return obj.Article_Name
            } else {
              return ''
            }
          } else {
            return ''
          }
        }
      },
      Store_Name() {
        return function (id) {
          if (this.store_info.length > 0) {
            let obj = this.store_info.filter(item => {
              return item.Store_SerialNumber == id
            })[0]
            if (obj) {
              return obj.Store_Name
            }else{
              return ''
            }
          } else {
            return ''
          }
        }
      },
      Supplier_Name() {
        return function (id) {
          if (this.supplier_info.length > 0) {
            let obj = this.supplier_info.filter(item => {
              return item.Supplier_SerialNumber == id
            })[0]
            if (obj) {
              return obj.Supplier_Name
            } else {
              return ''
            }       
          } else {
            return ''
          }
        }
      },
    },
    methods: {
      onSerach() {				//查询方法
        console.log("搜搜")
      },
      addContract() {
        console.log("跳转")
      },
      getList1() {
        let _this = this
        $.ajax({
          type: 'POST',
          url: DomainName + '/sv/GoodsFileInquiry',
          data: {
            Data: 'article_info'
          },
          success: function (data) {
            _this.article_info = data
            console.log(data);
          },
          dataType: "json"
        });
        $.ajax({
          type: 'POST',
          url: DomainName + '/sv/GoodsFileInquiry',
          data: {
            Data: 'store_info'
          },
          success: function (data) {
            _this.store_info = data
          },
          dataType: "json"
        });
        $.ajax({
          type: 'POST',
          url: DomainName + '/sv/GoodsFileInquiry',
          data: {
            Data: 'supplier_info'
          },
          success: function (data) {
            _this.supplier_info = data
          },
          dataType: "json"
        });
        $.ajax({
          type: 'POST',
          data: {
            Data: 'order_info'
          },
          url: DomainName + '/sv/GoodsFileInquiry',
          success: function (data) {
            _this.tableData = data.filter(item =>{
              return item.Row_Status == '0'
            })
          },
          dataType: "json"
        });
      },
      getList() {     //换页方法
        let _this = this
        $.ajax({
          type: 'POST',
          //	url: "../getContractListByConditionAction",
          url: "../getListByTableNameAction",
          data: {
            Data: "enterprise_info"
          },
          complete: function (XMLHttpRequest) {
            if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
              window.parent.document.location.href = XMLHttpRequest.getResponseHeader("CONTENTPATH");
            }
          },
          success: function (Result) {
            console.log(Result);
            _this.tableData = Result      //将获取的数据存到表格数据中
          },
          dataType: "json"
        });
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
        console.log(this.multipleSelection);
      },
      Confirm(Order_SerialNumber){
        let _this = this
        this.$confirm('确认发货, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        }).then(() => {
          $.ajax({
            type: 'POST',
            data: {
              Order_SerialNumber
            },
            url: DomainName + '/sv/Supplier_Confirm',
            success: function (res) {
              if (res.Status=="success") {
                _this.$message({
                  type:'success',
                  message:'确认成功'
                })
                _this.getList1()
              }else{
                _this.$message({
                  type: 'info',
                  message: '确认失败请从试！'
                });
              }
            },
            dataType: "json"
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消！'
          });
        });
      },
      Refused(Order_SerialNumber){
        let _this = this
        this.$confirm('拒绝发货, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        }).then(() => {
          $.ajax({
            type: 'POST',
            data: {
              Order_SerialNumber
            },
            url: DomainName + '/sv/Supplier_Refused',
            success: function (res) {
              if (res.Status=="success") {
                _this.$message({
                  type:'success',
                  message:'拒绝成功'
                })
                _this.getList1()
              }else{
                _this.$message({
                  type: 'info',
                  message: '拒绝失败请从试！'
                });
              }
            },
            dataType: "json"
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消！'
          });
        });
      }
    },
  })